package com.duolebo.uteped_sdk.model;

import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.database.Cursor;

import com.yc.nadalsdk.bean.FitnessStepData;

import java.util.ArrayList;

/**
 * @Author: wudapeng
 * @Date: 2023/12/25 20:12
 * @Description:
 */
public class StepModel extends BaseModel {
    private String calendarTime;
    private String calendar;
    private int time;
    private int startTime;
    private int endTime;
    private int step;
    private float calories;
    private int distance;
    private int offset;
    private int type;

    public StepModel(FitnessStepData data) {
        this.calendar = data.getCalendar();
        this.calendarTime = data.getCalendarTime();
        this.time = data.getTime();
        this.startTime = data.getStartTime();
        this.endTime = data.getEndTime();
        this.step = data.getStep();
        this.calories = data.getCalories();
        this.distance = data.getDistance();
        this.offset = data.getOffset();
        this.type = data.getType();
    }

    public StepModel(){}

    /**
     * BaseModel
     *
     * @param model model
     */
    StepModel(BaseModel model) {
        super(model);
    }

    @Override
    public void writeFieldValues(ContentValues values) {
        super.writeFieldValues(values);
        values.put(StepFields.CALENDAR_TIME, calendarTime);
        values.put(StepFields.CALENDAR, calendar);
        values.put(StepFields.TIME, time);
        values.put(StepFields.START_TIME, startTime);
        values.put(StepFields.END_TIME, endTime);
        values.put(StepFields.STEP, step);
        values.put(StepFields.CALORIES, calories);
        values.put(StepFields.DISTANCE, distance );
        values.put(StepFields.OFFSET, offset);
        values.put(StepFields.TYPE, type);
    }

    @SuppressLint("Range")
    @Override
    public void readFieldValues(Cursor c) {
        super.readFieldValues(c);
        calendarTime = c.getString(c.getColumnIndex(StepFields.CALENDAR_TIME));
        calendar = c.getString(c.getColumnIndex(StepFields.CALENDAR));
        time = c.getInt(c.getColumnIndex(StepFields.TIME));
        startTime = c.getInt(c.getColumnIndex(StepFields.START_TIME));
        endTime = c.getInt(c.getColumnIndex(StepFields.END_TIME));
        step = c.getInt(c.getColumnIndex(StepFields.STEP));
        calories = c.getInt(c.getColumnIndex(StepFields.CALORIES));
        distance = c.getInt(c.getColumnIndex(StepFields.DISTANCE));
        offset = c.getInt(c.getColumnIndex(StepFields.OFFSET));
        type = c.getInt(c.getColumnIndex(StepFields.TYPE));
    }

    @Override
    public void prepareFieldDefs(ArrayList<String> fieldDefs) {
        super.prepareFieldDefs(fieldDefs);
        fieldDefs.add(StepFields.CALENDAR_TIME + FIELD_TYPE_TEXT);
        fieldDefs.add(StepFields.CALENDAR + FIELD_TYPE_TEXT);
        fieldDefs.add(StepFields.TIME + FIELD_TYPE_INTEGER);
        fieldDefs.add(StepFields.START_TIME + FIELD_TYPE_INTEGER);
        fieldDefs.add(StepFields.END_TIME + FIELD_TYPE_INTEGER);
        fieldDefs.add(StepFields.STEP + FIELD_TYPE_INTEGER);
        fieldDefs.add(StepFields.CALORIES + FIELD_TYPE_REAL);
        fieldDefs.add(StepFields.DISTANCE + FIELD_TYPE_INTEGER);
        fieldDefs.add(StepFields.OFFSET + FIELD_TYPE_INTEGER);
        fieldDefs.add(StepFields.TYPE + FIELD_TYPE_INTEGER);
    }

    public static class StepFields implements Fields {
        public static final String CALENDAR_TIME = "calendar_time";
        public static final String CALENDAR = "calendar";
        public static final String TIME = "time";
        public static final String START_TIME = "start_time";
        public static final String END_TIME = "end_time";
        public static final String STEP = "step";
        public static final String CALORIES = "calories";
        public static final String DISTANCE = "distance";
        public static final String OFFSET = "offset";
        public static final String TYPE = "type";
    }

    public String getCalendarTime() {
        return calendarTime;
    }

    public void setCalendarTime(String calendarTime) {
        this.calendarTime = calendarTime;
    }

    public String getCalendar() {
        return calendar;
    }

    public void setCalendar(String calendar) {
        this.calendar = calendar;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public int getStartTime() {
        return startTime;
    }

    public void setStartTime(int startTime) {
        this.startTime = startTime;
    }

    public int getEndTime() {
        return endTime;
    }

    public void setEndTime(int endTime) {
        this.endTime = endTime;
    }

    public int getStep() {
        return step;
    }

    public void setStep(int step) {
        this.step = step;
    }

    public float getCalories() {
        return calories;
    }

    public void setCalories(float calories) {
        this.calories = calories;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

}
